package hu.issue.framework.web.tag;

import hu.issue.framework.security.SecurityContext;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class InRoleTag extends TagSupport {
	private String roleName;

	public void setRole(final String roleName) {
		this.roleName = roleName;
	}

	@Override
	public int doStartTag() throws JspException {
		if (SecurityContext.isCurrentUserInRow(this.roleName)) {
			return EVAL_BODY_INCLUDE;
		} else {
			return SKIP_BODY;
		}
	}
}
